@echo off

setlocal 
%~d0
cd "%~dp0"

Set servername=".\SQLEXPRESS"

echo.
echo ========= Creating GEXCOMERDb database =========
SqlCmd -S %servername% -E -i sql\GEXCOMER\Schema\GEXCOMERDb.sql

echo ========= Creating GEXCOMERDb tables =========
SqlCmd -S %servername% -E -i sql\GEXCOMER\Schema\dbo.CPARTIC.Table.sql
SqlCmd -S %servername% -E -i sql\GEXCOMER\Schema\dbo.CPMARCA.Table.sql
SqlCmd -S %servername% -E -i sql\GEXCOMER\Schema\dbo.STSUCUR.Table.sql
SqlCmd -S %servername% -E -i sql\GEXCOMER\Schema\dbo.CPPROVE.Table.sql
SqlCmd -S %servername% -E -i sql\GEXCOMER\Schema\dbo.DPDPCHO1.Table.sql

echo.
echo ========= Creating GEXCOMERDb triggers ========= 
SqlCmd -S %servername% -E -i sql\GEXCOMER\Triggers\Actualizar_Suc_OnUpdate.Trigger.sql
SqlCmd -S %servername% -E -i sql\GEXCOMER\Triggers\Agregar_Imei_OnInsert.Trigger.sql
SqlCmd -S %servername% -E -i sql\GEXCOMER\Triggers\Agregar_Imei_OnUpdate.Trigger.sql
SqlCmd -S %servername% -E -i sql\GEXCOMER\Triggers\Agregar_Suc_OnInsert.Trigger.sql

echo.
echo ========= Adding GEXCOMERDb sample data ========= 
SqlCmd -S %servername% -E -i sql\GEXCOMER\Data\dbo.STSUCUR.Data.sql
SqlCmd -S %servername% -E -i sql\GEXCOMER\Data\dbo.CPMARCA.Data.sql
SqlCmd -S %servername% -E -i sql\GEXCOMER\Data\dbo.CPPROVE.Data.sql
SqlCmd -S %servername% -E -i sql\GEXCOMER\Data\dbo.CPARTIC.Data.sql
SqlCmd -S %servername% -E -i sql\GEXCOMER\Data\dbo.DPDPCH01.Data.sql

echo.
PAUSE